<%@ page language="java" import="java.util.*,shop.dao.*,shop.entity.*"  pageEncoding="utf-8"%>
<%
		String title = new String(request.getParameter("title").getBytes("ISO-8859-1"),"utf-8");
		String contents = new String(request.getParameter("contents").getBytes("ISO-8859-1"),"utf-8");
         String username = (String)session.getAttribute("username");

		News News=new News();
		News.setTitle(title);
		News.setContents(contents);
		News.setWriterMEN(username);

		NewsDao NewsDao = new NewsDao();
         int count = NewsDao.insertNews(News);
		     if (count > 0)
			out
			.print("<script type='text/javascript'>alert('成功添加新闻。');location.replace('NEWS_list.jsp');</script>");
	     else
			out
			.print("<script type='text/javascript'>alert('添加新闻失败或格式错误！。');history.go(-1);</script>");
     	
%>